<?php

namespace App\Http\Controllers\Web;

use App\ConstDir\ErrorConst;
use App\Repository\Repositories\Interfaces\SysArticleRepository;

/**
 * 订单管理控制器
 *
 * @package App\Http\Controllers\Backend
 */
class ArticleController extends BaseController
{
    /**
     * @var SysArticleRepository
     */
    protected $article;

    public function __construct(SysArticleRepository $article)
    {
        $this->article = $article;

    }

    public function index(){
        $products = $this->article->scopeQuery(function($sql){
            return $sql->where('fid',27);
        })->orderBy('id','desc')->paginate(4);
        return $this->success(ErrorConst::SUCCESS_CODE_MSG, $products, true);
    }


    public function show($id){
        $new_info = $this->article->find($id);
        $up_new =  $this->article->upDownNewList($id);
        $data = ['info'=>$new_info,'updown'=>$up_new];
        return $this->success(ErrorConst::SUCCESS_CODE_MSG, $data, true);
    }
    public function index_list(){
        $articles = $this->article->paginate($this->perPage);
        return $this->success(ErrorConst::SUCCESS_CODE_MSG, $articles, true);
    }



}
